package com.crm.business.crm.service;

import com.alibaba.fastjson.JSONObject;
import com.crm.common.crm.common.CrmModel;
import com.crm.common.crm.entity.BO.*;
import com.crm.common.crm.entity.PO.CrmReceivables;
import com.crm.common.crm.entity.VO.CrmInfoNumVO;
import com.crm.common.crm.entity.VO.CrmModelFiledVO;
import com.crm.common.crm.entity.VO.CrmRoiStatisVO;
import com.crm.common.ka.core.entity.BasePage;
import com.crm.business.servlet.BaseService;
import com.crm.common.ka.core.servlet.upload.FileEntity;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 回款表 服务类
 * </p>
 *
 * @author zhangzhiwei
 * @since 2020-05-28
 */
public interface ICrmReceivablesService extends BaseService<CrmReceivables> {
    /**
     * 查询字段配置
     *
     * @param id 主键ID
     * @return data
     */
    public List<CrmModelFiledVO> queryField(Integer id);

    /**
     * 查询导入字段配置
     *
     * @param id 主键ID
     * @return data
     */
    public List<CrmModelFiledVO> queryExportField(Integer id);

    /**
     * 分页查询
     *
     * @param search
     * @return
     */
    public BasePage<Map<String, Object>> queryPageList(@RequestBody CrmSearchBO search);

    /**
     * 查询字段配置
     *
     * @param id 主键ID
     * @return data
     */
    public CrmModel queryById(Integer id);

    /**
     * 查询字段配置
     * @param id 主键ID
     * @return data
     */
    public CrmModel queryReturnTypeById(Integer id);

    /**
     * 保存或新增信息
     *
     * @param crmModel model
     */
    public void addOrUpdate(CrmContractSaveBO crmModel);

    /**
     * 删除回款数据
     *
     * @param ids ids
     */
    public void deleteByIds(List<Integer> ids);

    /**
     * 修改回款负责人
     *
     * @param receivablesIds       回款id列表
     * @param newOwnerUserId 新负责人ID
     */
    public void changeOwnerUser(List<Integer> receivablesIds, Long newOwnerUserId);

    /**
     * 修改回款讲师负责人
     * @param ownerUserBO
     */
    public void changeTeacherUser(CrmChangeOwnerUserBO ownerUserBO);

    /**
     * 全部导出
     *
     * @param response resp
     * @param search   搜索对象
     */
    public void exportExcel(HttpServletResponse response, CrmSearchBO search);

    /**
     * 查询文件数量
     *
     * @param id id
     * @return data
     */
    public CrmInfoNumVO num(Integer id);

    /**
     * 查询文件列表
     * @param id id
     * @return file
     */
    public List<FileEntity> queryFileList(Integer id);

    /**
     * 查询详情信息
     * @param receivablesId 回款ID
     * @return data
     */
    public List<CrmModelFiledVO> information(Integer receivablesId);

    void updateInformation(CrmUpdateInformationBO updateInformationBO);

    BasePage<JSONObject> queryListByContractId(BasePage<JSONObject> page, Integer contractId, String conditions);

    /**
     * 回款记录  更新客户成交状态
     * @param receivables
     */
    public void updateCustomerDeal(CrmReceivables receivables, boolean changeData);

    /**
     * 根据客户Id查询客户下回款信息总数（审批中及审批通过）
     * @param customerId
     * @return
     */
    Integer queryCountReceivablesByCustomerId(Integer customerId);
    Integer queryCountReceivablesByStudentId(Integer studentId);

    List<JSONObject> queryReceivablesByThreeOrderNo(String threePartOrderNo);

    public List<JSONObject> queryReceivablesByThreeOrderNoByChect(String threePartOrderNo);

    public List<JSONObject> queryReceivablesByStudentCell(String studentCell);

    public List<String> queryOverdueStatus();

    /**
     * 还款计划审核通过
     * @param id
     */
    public void checkStatus(Integer id);

    /**
     * 下载导入模板
     *
     * @param response resp
     * @throws IOException ex
     */
    public void downloadExcel(HttpServletResponse response) throws IOException;

    /**
     * 导入账单分期回款数据
     * @param crmModel
     */
    public void importBillData(CrmContractSaveBO crmModel);

    public List<Map<String,Object>> queryPutinStatis(List<Integer> customerIds,List<Long> userIdList);

    public List<Map<String,Object>> queryAllPutinStatis(List<Integer> customerIds,List<Long> userIdList);

    public List<CrmRoiStatisVO> queryRoiStatis(String startDate, String endDate);

    public List<CrmRoiStatisVO> queryExpectRoiStatis(String startDate, String endDate);

    public BigDecimal queryReceivablesMoneyByData(CrmRoiPutinPageBO crmRoiPutinPageBO);

    public BigDecimal queryExpectReceivablesMoneyByData(CrmRoiPutinPageBO crmRoiPutinPageBO);

    public List<CrmRoiStatisVO> queryPutinStatisByFormDate(CrmRoiPutinPageBO crmRoiPutinPageBO);

    public List<CrmRoiStatisVO> queryExpectPutinStatisByFormDate(CrmRoiPutinPageBO crmRoiPutinPageBO);




}
